package com.hzit.listener;

import javax.servlet.*;
import javax.servlet.annotation.WebListener;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@WebListener
public class MyRequestListener implements ServletRequestListener, ServletRequestAttributeListener {
	//1. 请求被创建时调用
	@Override
	public void requestInitialized(ServletRequestEvent sre) {
		//1.1 取得创建的application对象
		ServletContext servletContext = sre.getServletContext();

		System.out.println("请求创建成功。");
	}
	//2. 请求被销毁时调用
	@Override
	public void requestDestroyed(ServletRequestEvent sre) {
		System.out.println("请求被销毁。");
	}

	//3. req.setAttribute()时调用：
	@Override
	public void attributeAdded(ServletRequestAttributeEvent srae) {
		System.out.println("添加请求属性.");
	}

	//4. req.removeAttribute()时调用。
	@Override
	public void attributeRemoved(ServletRequestAttributeEvent srae) {
		System.out.println("移除请求属性。");
	}

	@Override
	public void attributeReplaced(ServletRequestAttributeEvent srae) {

	}

}
